angular.module('starter.filters', [])

.filter("filterExist", function () {
    return function (sourceList, existList) {
        var results = sourceList.filter(function(item) {
            var isExist = false;
            for (var i = existList.length - 1; i >= 0; i--) {
                if(existList[i].id == item.id){
                    isExist = true;
                    break;
                }
            };
            return !isExist;
        });
        
        return results;
    };
})

.filter("displayDate", function () {
    return function (input) {
        var inputdate = Date.parse(input, "yyyy/MM/dd");
        if (Date.today().equals(inputdate)) {
            return "今天";
        } else if (Date.today().addDays(1).equals(inputdate)) {
            return "明天";
        } else {
            return input;
        }
    }
})
